-
Notifications
You must be signed in to change notification settings - Fork 973
Conversation
3e4eabf
to
451cf04
Compare
app/renderer/components/window.js
Outdated
@@ -93,11 +96,14 @@ class Window extends React.Component { | |||
|
|||
componentDidMount () { | |||
appActions.windowReady(getCurrentWindowId()) | |||
this.updateComputedStyles() | |||
window.addEventListener('resize', this.updateComputedStyles) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we already have a window resize handler in windows.js that triggers appActions.windowUpdated
and it is debounced to prevent a flood of actions during resize. I think it would be better to send that action to the window using queryInfo (see urlBarTextChanged
for an example) and update the computed styles in response to that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
app/renderer/components/window.js
Outdated
@@ -45,6 +47,7 @@ class Window extends React.Component { | |||
|
|||
this.onChange = this.onChange.bind(this) | |||
this.onAppStateChange = this.onAppStateChange.bind(this) | |||
this.updateComputedStyles = throttle(this.updateComputedStyles.bind(this), 66) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can get rid of this and rely on the existing windowUpdated
debounce
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved into windows.js
js/actions/appActions.js
Outdated
@@ -1411,6 +1411,14 @@ const appActions = { | |||
dispatch({ | |||
actionType: appConstants.APP_UPDATE_LOG_OPENED | |||
}) | |||
}, | |||
|
|||
updateComputedStyles: function (windowId, values) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should actually be in windowActions. We are generally moving away from windowActions and appActions, but we will keep windowActions for actions that are related to the window component. It can still be handled in the browser process
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also should be declarative updateComputedStyles
-> computedStylesChanged
or something similar
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
app/common/state/windowState.js
Outdated
@@ -148,6 +148,13 @@ const api = { | |||
return state.set('windows', windows.delete(index).insert(index, windowValue)) | |||
}, | |||
|
|||
updateComputedStyles: (state, action) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think setComputedStyles
and we are moving away from passing actions into state helpers so I think this should take windowId
and computedStyles
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
app/common/lib/windowsUtil.js
Outdated
return result | ||
} | ||
|
||
const getComputedProperty = (state, property) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be replaced by a getComputedStyles
method in windowState
. We don't want anything outside of windowState to be tightly coupled to the storage path
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved
I like the general idea, just needs some tweaks |
dae69f6
to
a4213bc
Compare
app/browser/windows.js
Outdated
appActions.windowUpdated(windowValue) | ||
updateComputedStyles(win) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only problem with calling this function from this file is that we don't have document, so you can't do document.querySelector
. Any idea how to fix this? @bridiver
a4213bc
to
bf7c248
Compare
@bridiver can you please checkout my review comment |
ca1a1a1
to
44c65ae
Compare
this.chevronWidth = this.chevronMargin + Number.parseInt(this.fontSize) | ||
} | ||
this.maxWidth = windowsUtil.getCSSElementProperty('bookmark-item-max-width') | ||
this.padding = windowsUtil.getCSSElementProperty('--bookmark-item-padding') * 2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these shouldn't have dashes, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are correct. Fixed
44c65ae
to
c1cfe7e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, maybe just some naming changes
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
const computedStyles = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this go under renderer
now instead of common
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
computed
also probably doesn't make sense anymore since these are static values
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, almost forgot. We should comment this file and the less files to make sure they don't get out-of-sync
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't want anyone to think they can only update one or the other
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would leave it here, because we have all constants files here and this are constants
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment added
app/common/lib/windowsUtil.js
Outdated
return Immutable.fromJS({ | ||
location: site.get('location'), | ||
order: site.get('order'), | ||
partitionNumber: site.get('partitionNumber') || 0 | ||
}) | ||
} | ||
|
||
const getCSSElementProperty = (prop) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe renderer/styleUtil
? getStyleValue
?
cd4775a
to
2c1c1be
Compare
please add comments to |
Resolves brave#9149 Auditors: Test Plan:
2c1c1be
to
e2df69a
Compare
Submitter Checklist:
git rebase -i
to squash commits (if needed).Resolves #9149
Auditors: @bsclifton @bridiver
Test Plan:
Reviewer Checklist:
Tests